﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.Mappings
{
    public class WarehouseMapping : IEntityTypeConfiguration<Warehouse>
    {
        public void Configure(EntityTypeBuilder<Warehouse> builder)
        {
            builder.HasQueryFilter(x => x.IsEnable);
            builder.Property(x => x.Code).HasMaxLength(10);
            builder.Property(x => x.Name).HasMaxLength(50);
            builder.Property(x => x.Address).IsRequired(false).HasMaxLength(80);
            builder.Property(x => x.ManageManName).IsRequired(false).HasMaxLength(20);
            builder.Property(x => x.Telephone).IsRequired(false).HasMaxLength(20);
            builder.Property(x => x.Attribute).HasMaxLength(50);
            builder.Property(x => x.Remark).IsRequired(false).HasMaxLength(500);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.Code);
            builder.HasIndex(x => x.Name);
            builder.HasIndex(x => x.CreatedOn).IsDescending();
        }
    }
}
